Angular

Argument of type 'string | null' is not assignable to parameter of type 'string'.\n Type 'null' is not assignable to type 'string'

Argument of type 'string | null' is not assignable to parameter of type 'string'.\n Type 'null' is not assignable to type 'string', someone asked me to explain?
web
I got this error because, while parsing JSON it is expecting string result. 

'null' is not assignable to type 'string'
So when you try to use localStorage.getItem() you may follow this way,

JSON.parse(localStorage.getItem('currentUser')|| '{}')


Post your comments / questions